/*
 * Keyboard.h
 *
 * Author: Samuel Queiroz
 */

#ifndef KEYBOARD_H_
#define KEYBOARD_H_

#define SPEED_UNITS 20
#define ROTATION_UNITS 10

#include "../Component/Button.h"
#include "../Component/Slider.h"
#include "../Component/Switcher.h"

#include "../Thread/Runnable.h"

#include "SDL/SDL.h"

class Keyboard
	: public Runnable
{

private:

	Slider *speedSlider;
	Slider *rotationSlider;

	Switcher robotSwitcher;
	Switcher controlSwitcher;

	SimpleButton upButton;
	SimpleButton downButton;
	SimpleButton leftButton;
	SimpleButton rightButton;

	SimpleButton stopButton;

	SDL_Event *event;
	SDL_Event *lastEvent;

	/**
	 * Check the pressed key and do the correct action.
	 */
	void switchPressedKey(SDL_keysym *keysym);

	/**
	 * Check the released key and do the correct action.
	 */
	void switchReleasedKey(SDL_keysym *keysym);

	void run();

public :

	Keyboard(int speedUnits, int rotationUnits, SDL_Event *event)
	{
		this->event = event;
		this->lastEvent = NULL;
		this->speedSlider = new Slider(speedUnits);
		this->rotationSlider = new Slider(rotationUnits);
	}

	~Keyboard()
	{

	}

	inline SimpleButton *getUpButton()
	{
		return &upButton;
	}

	inline SimpleButton *getDownButton()
	{
		return &downButton;
	}

	inline SimpleButton *getLeftButton()
	{
		return &leftButton;
	}

	inline SimpleButton *getRightButton()
	{
		return &rightButton;
	}

	inline SimpleButton *getStopButton()
	{
		return &stopButton;
	}

	inline Slider *getSpeedSlider()
	{
		return speedSlider;
	}

	inline Slider *getRotationSlider()
	{
		return rotationSlider;
	}

	inline Switcher *getRobotSwitcher()
	{
		return &robotSwitcher;
	}

	inline Switcher *getControlSwitcher()
	{
		return &controlSwitcher;
	}

};

#endif
